package controller;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SearchLinkServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		String name = req.getParameter("name");
		
		String domainName=Utils.fomatDomain(name);
		
		if(Utils.checkDomain(domainName))
		{
			resp.sendRedirect("/link/"+name);
			return;
		} else {
			resp.sendRedirect("/gsearch?cx=009050056988840974278:fjfndh0x9ws&cof=FORID%3A10&ie=UTF-8&q="+name+"&sa=Search");
		}
		
	}
}
